<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改友情链接</title>
    <link href="../../css/admin/style.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-1.8.3.min.js" type="text/javascript"></script >
    <script>
        $(function (){
            var id = location.search.split("=")[1];
            $("#id").val(id);
            $.get("../../friendlink/getLinkById",{id:id},function (res){
                $("input[name='linkname']").val(res.data.linkname);
                $("input[name='url']").val(res.data.url);
            },"json")
        })
        //保存
        function updatelink() {
            $.post("../../friendlink/updatefriendlink", $("#formId").serialize(), function (res) {
                if (res.code == 202){
                    window.parent.location.replace("../login.html");
                }else if (res.code == 500){
                    alert(res.msg);
                } else {
                    alert("修改成功");
                    location.replace("list.html");
                }
            });
        }

        function goback(){
            location.replace("list.html")
        }
    </script>
</head>
<body>
<div class="formbody">
    <div class="formtitle"><span>基本信息</span></div>
    <form id="formId">
        <input type="hidden" name="id" id="id">
        <ul class="forminfo">
            <li>
                <label>友情链接名:</label>
                <input name="linkname" type="text" class="dfinput" onblur="checkName()"/>
                <span id="checkSpan"></span>
            </li>
            <li>
                <label>友情链接:</label>
                <input name="url" type="text" class="dfinput"/>
            </li>

            <li>
                <input name="" type="button"  value="确认修改" onclick="updatelink()"/>
                <input name="" type="button"  value="返回" onclick="goback()"/>
            </li>
        </ul>
    </form>
</div>
</body>
</html>